package com.joker.coupon.controller;

import com.joker.common.core.domain.Result;
import com.joker.coupon.domain.PmsCoupon;
import com.joker.coupon.service.PmsCouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("coupon")
public class PmsCouponController {

    @Autowired
    private PmsCouponService pmsCouponService;

    @GetMapping("/list/{recommendStatus}")
    public Result selectHomePageCoupon(@PathVariable Integer recommendStatus) {
        return Result.success(pmsCouponService.selectHomePageCoupon(recommendStatus));
    }

    @PostMapping("/receiveCoupon/{skuId}")
    public Result receiveCoupon(@PathVariable Long skuId) {
        pmsCouponService.receiveCoupon(skuId);
        return Result.success();
    }

    @GetMapping("/selectCouponBySkuId/{skuId}")
    public Result selectCouponBySkuId(@PathVariable Long skuId) {
        return Result.success(pmsCouponService.selectCouponBySkuId(skuId));
    }

    @GetMapping("/selectCouponByCart/{skuId}")
    public Result<List<PmsCoupon>> selectCouponByCart(@PathVariable(name = "skuId") Long skuId) {
        List<PmsCoupon> pmsCouponList = pmsCouponService.selectCouponByCart(skuId);
        return Result.success(pmsCouponList);
    }

    @GetMapping("/selectUserCoupon/{status}")
    public Result selectUserCoupon(@PathVariable Long status){
        return Result.success(pmsCouponService.selectUserCoupon(status));
    }

    @GetMapping("/selectCouponByOrder")
    public Result selectCouponByOrder(){
        return Result.success(pmsCouponService.selectCouponByOrder());
    }

    @GetMapping("/computeDiscountPrice/{couponId}")
    public Result<PmsCoupon> computeDiscountPrice(@PathVariable Long couponId){
        return Result.success(pmsCouponService.computeDiscountPrice(couponId));
    }


}
